#include <bits/stdc++.h>
using namespace std;

class Solution
{
public:
    int main()
    {
        int operationCount;
        cin >> operationCount;
        int maxReached = 0;
        vector<pair<double, int>> operations;
        operations.reserve(operationCount);
        for (int i = 0; i < operationCount; ++i)
        {
            double a;
            int t;
            cin >> a >> t;
            operations.push_back({a, t});
            maxReached = max(maxReached, static_cast<int>(a * t));
        }
        vector<int> lights(maxReached + 1, 0);
        for (auto &operation : operations)
        {
            for (int i = 1; i <= operation.second; ++i)
            {
                int id = static_cast<int>(i * operation.first);
                lights[id] = !lights[id];
            }
        }
        for (int i = 1; i <= maxReached; ++i)
        {
            if (lights[i] == 1)
            {
                cout << i;
                break;
            }
        }
        return 0;
    }
};

#ifndef __LOCAL_TEST__
int main()
{
    return Solution().main();
}
#endif